<!DOCTYPE html>
<html lang="zh">
<head>
  <#assign title="修改密码">
  <#include "/head.html">
</head>
  
<body>
<div class="container-fluid p-t-15">
  
  <div class="row">
    
    <div class="col-lg-12">
      <div class="card">
        <div class="card-body">
          
          <form id="submitForm" method="post" action="" class="site-form">
            <div class="form-group">
              <label for="old-password">旧密码</label>
              <input type="password" class="form-control" name="oldpwd" id="old-password" placeholder="输入账号的原登录密码">
            </div>
            <div class="form-group">
              <label for="new-password">新密码</label>
              <input type="password" class="form-control" name="newpwd" id="new-password" placeholder="输入新的密码">
            </div>
            <div class="form-group">
              <label for="confirm-password">确认新密码</label>
              <input type="password" class="form-control" name="confirmpwd" id="confirm-password" placeholder="请确认新密码">
            </div>
          </form>
          
          <button class="btn btn-primary" onclick="doSubmit()">修改密码</button>
       
        </div>
      </div>
    </div>
    
  </div>
  
</div>

<#include "/footer.html">

<script>
validateForm({
	'oldpwd': {
		required: true
	},
	'newpwd': {
		required: true,
		minlength: 5
	},
	'confirmpwd': {
		required: true,
		minlength: 5,
		equalTo: '#new-password'
	}
});

function doSubmit() {
	var $form = $('#submitForm');
	
	if (!$form.valid()) {
		return;
	}

	ajaxPost({ 
		url: 'system/user/updatePwd',
		data: $form.serialize(),
		success: function(r) {
			if (r.code == 0) {
				layer.alert('修改成功，请重新登录', function (index) {
					window.top.location.href = 'login';
				});
			} else {
				notifyWarning(r.message);
			}
		}
	});
}
</script>

</body>
</html>